import re
from MetroNorthDao import MetroNorthDao
import datetime

now = datetime.datetime.now()



day = now.strftime("%m/%d/%Y")
time = now.strftime("%I:30")
tz = now.strftime("%p")
print day
print time
print tz

PATTERN_OBJECT = re.compile('TRAIN:\s*(\S+),\s*(\S+),\s*(\S+),\s*(\S+),\s*(\S+)')

cmd = "TRAIN:DARIEN,STAMFORD, 1/02/2010, 12, AM".upper()

print "%s" % cmd

matchGroups = PATTERN_OBJECT.match(cmd)
if matchGroups :
    start = matchGroups.group(1)
    end = matchGroups.group(2)
    day = matchGroups.group(3)
    time = "%s:00" % matchGroups.group(4)
    tz = matchGroups.group(5)
    print "%s,%s, %s, %s, %s" % (start, end, day, time, tz)
    
    dao = MetroNorthDao() 
    trains = dao.getSchedulesByName(start, end, day, time, tz) 
    print "Trains:"
    for train in trains:
        print "%s %s" % (train[0],train[1])
        

stations = dao.getStations()

x = sorted(stations.itervalues())
           
#for v in x:
#    print "%s" % (v)
    

